<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link href="<%=request.getContextPath()%>/css/global.css" type="text/css" rel="stylesheet" />
<link href="<%=request.getContextPath() %>/js/easyui/themes/metro/easyui.css" type="text/css" rel="stylesheet"/>
<link href="<%=request.getContextPath() %>/js/ztree/css/zTreeStyle/zTreeStyle.css" type="text/css" rel="stylesheet"/>
<script type="text/javascript" src="<%=request.getContextPath() %>/js/jquery.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/js/global.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/js/easyui/easyui.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/js/ztree/ztree.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/js/ztree/ztree.excheck.js"></script>
<script type="text/javascript">

$(function(){
	$.fn.zTree.init($("#funTree"), setting, <s:property value="funTree" escape="false"/>);
	var zTree = $.fn.zTree.getZTreeObj("funTree")
	zTree.expandAll(true);
	var nodes = zTree.transformToArray (zTree.getNodes());

	$.getJSON("rof_ajaxoxf.html?optNo=<s:property value="operatorBean.optNo"/>&time="+Math.random(),
			function(data){
			  $.each(data, function(i,item){
				  var node = zTree.getNodeByParam("funNo", item.funNo);
           	  		 zTree.checkNode(node,true,true);
			});
		}); 
	$.getJSON("rof_ajaxrole.html?time="+Math.random(),
			function(data){
			  $.each(data, function(i,item){
				   $("#rolNo").append("<option value='"+item.rolNo+"'>"+item.rolName+"</option>");
			});
		}); 
});
var setting = {
	check: {
		autoCheckTrigger:true,
		enable: true,
		chkboxType :{
			"Y" : "",
			"N" : ""
			}
	},
	data: {
		key:{
			name:'funName',
			title:'funName'
		},
		simpleData: {
			enable: true,
			idKey:'funNo',
			pIdKey:'funDad',
			rootPid:-1
		}
	},
	callback: {
		onCheck: function(e, treeId, treeNode) {
			if(treeNode.checked){
				$.ajax({
					   type: "POST",
					   cache: false,
					   async: false,
					   url: "rof_saveoxf.html",
					   data: "optNo=<s:property value="operatorBean.optNo"/>&funNo="+treeNode.funNo+"&time="+Math.random(),
					   success: function(msg){
					     
					   }
					}); 
			}else{
				$.ajax({
					   type: "POST",
					   cache: false,
					   async: false,
					   url: "rof_moveoxf.html",
					   data: "optNo=<s:property value="operatorBean.optNo"/>&funNo="+treeNode.funNo+"&time="+Math.random(),
					   success: function(msg){
					     
					   }
					}); 
			}
		}	
	}
};

function oxr(){
	var optNo='<s:property value="operatorBean.optNo"/>';
	var rolNo=$("#rolNo").val();
	$.ajax({
		   type: "POST",
		   cache: false,
		   async: false,
		   url: "rof_saveoxr.html",
		   data: "optNo="+optNo+"&rolNo="+rolNo+"&time="+Math.random(),
		   success: function(msg){
			   location.reload();
		   }
		}); 
}

</script>
</head>
<body >
 	<div class="easyui-panel" title="关联面板" style="width:100%;" data-options="fit:true">
		<table width="600" border="0" style="margin: 5px;">
		<tr><td height="25" colspan="2"><b>操作说明:可以直接对操作员进行功能菜单分配,也可以选择一个角色模版直接套用</b></td></tr>
		<tr>
		<td width="40%" valign="top">
			<table width="100%" border="0">
				<tr><td height="25">操作员信息</td></tr>
				<tr><td height="25">所属部门 : <s:property value="operatorBean.catNo"/></td></tr>
				<tr><td height="25">工号 : <s:property value="operatorBean.optId"/></td></tr>
				<tr><td height="25">姓名 : <s:property value="operatorBean.optName"/></td></tr>
				<tr><td height="25"></td></tr>
				<tr><td height="25">套用角色模版 : </td></tr>
				<tr><td height="25"><select name="rolNo" id="rolNo" style="width: 160px;" /><input type="button" class="submit" value="应用模版" onclick="oxr();"/></td></tr>
				<tr><td height="25"></td></tr>
			</table>
		</td>
		
		<td width="60%" valign="top">
			<table width="100%"  border="0">
				<tr><td height="25">点选功能项即生效</td></tr>
				<tr>
				<td height="25">
					<ul id="funTree" class="ztree"></ul>
				</td>
				</tr>
			</table>
		</td>
		</tr>
		<tr>
			<td colspan="2" >
				<input type="button" class="submit" value="返回前页" onclick="location.href='<%=request.getContextPath()%>/rof_listoperator.html'">
			</td>
		</tr>
	</table>
		
	</div>
</body>
</html>

